const formatArray = (arr = []) => {
    const myArr = [];
    for (const obj of arr) {
        myArr.push(formatObject(obj));
    }
    return myArr;
}

const formatObject = (obj = {}) => {
    for (const key in obj) {
        if (key.includes("_")) {
            const keys = key.split("_");
            let k = keys[0];
            for (let i = 1; i < keys.length; i++) {
                let name = keys[i];
                let n = name.substring(0, 1).toUpperCase();
                let e = name.substring(1);
                name = n + e;
                k += name;
            }
            obj[k] = obj[key];
            delete obj[key];
        }
    }
    return obj;
}

module.exports = {formatArray, formatObject}
